package main

import (
// "log"
//"errors"
)

type Creature struct {
	Item
	isMale    bool
	isAlive   bool
	energy    int
	tiredness int
}

func NewCreature(item Item, isMale bool) *Creature {
	return &Creature{item, isMale, true, 100, 0}
}

// todo: make sure destination is valid
func (this Creature) Move(direction Direction) {
	destination := this.Location().neighbours[direction]
	this.Location().remove(this)
	destination.put(this)
}

// todo: error handling, when not found
// todo: was ist mit zeug, das im inventar ist?
func (this Creature) Examine(entity string) string {

	return getItemByName(entity, this.location.items).Description()
}

func (this Creature) IsAlive() bool {

	return this.isAlive

}

func (this Creature) IsMale() bool {

	return this.isMale
}

func (this *Creature) Eat(food Edible) {
	this.energy += food.Energy()
}

func (this *Creature) sleep(duration int) {
	this.tiredness = this.tiredness - duration*20
	if this.tiredness < 0 {
		this.tiredness = 0
	}
}
